import { defineStore } from 'pinia';
import { getToken, removeToken, setToken } from '../utils/token-utils';
// import type { UserInfoState } from './interface';
// import {ElMessage} from 'element-plus'
// import { staticRoutes, allAsyncRoutes, anyRoute } from '@/router/routes'
// import userinfoApi from '@/api/userInfo'
// import type { RouteRecordRaw } from "vue-router";
import type { InfoModel } from '@/api/login'
// import router from '@/router'
// import { cloneDeep } from 'lodash';

// 创建一个空的用户信息,用来初始化store.userinfo和reset
const resetUserinfo = () => ({
    name: '',
    avatar: '',
    buttons: [],
    roles: [],
    routes: [],
  })
  // 用户信息包括权限数据
export interface UserInfoState {
    token: string;
    userinfo: InfoModel;
    hobby: hobbyModel;
    showModel:boolean,
    route : string
  }
  //组件hobby
  export interface hobbyModel {
    isShow: boolean;
    hobbyList: objModel[];
    userHobby: string[];
    filterHobbies:objModel[];
  }
  export interface  objModel {
    groupType:string;
    name:string;
    id:string;
  }

export const useUserInfoStore = defineStore('userInfo', {

	state: (): UserInfoState => ({
    token: getToken() as string,
    // 用户信息改了,所有涉及到获取用户信息的地方都需要改
    // 1. router.beforeEach 通过获取用户名判断登录
    // 2. 首页 hello, admin -> 用户名获取方式改变
    // 3. navBar 用户名和头像的展示
    route:'',
    showModel:false,
    userinfo: resetUserinfo(),
    hobby: {
      isShow: false,
      filterHobbies : [],
      hobbyList : [
        {
          "groupType":"avocation",
          "name":"古典舞",
          "id":"402881ed649d628e01649d636ea7005b"
        },
        {
          "groupType":"avocation",
          "name":"街舞",
          "id":"402881ed649d628e01649d636ea60056"
        },
        {
          "groupType":"avocation",
          "name":"民族舞",
          "id":"402881ed649d628e01649d636ea7005a"
        },
        {
          "groupType":"avocation",
          "name":"肚皮舞",
          "id":"402881ed649d628e01649d636ea7005f"
        },
        {
          "groupType":"avocation",
          "name":"中国舞",
          "id":"ff80808167bef94f0167bf6f6e0a1fd2"
        },
        {
          "groupType":"avocation",
          "name":"爵士舞",
          "id":"402881ed649d628e01649d636ea70057"
        },
        {
          "groupType":"avocation",
          "name":"流行热舞",
          "id":"402881ed649d628e01649d636ea80065"
        },
        {
          "groupType":"avocation",
          "name":"芭蕾舞",
          "id":"402881ed649d628e01649d636ea70059"
        },
        {
          "groupType":"avocation",
          "name":"现代舞",
          "id":"402881ed649d628e01649d636ea70058"
        },
        {
          "groupType":"avocation",
          "name":"舞蹈",
          "id":"ff80808167cb37250167cc06bbec356a"
        },
        {
          "groupType":"avocation",
          "name":"拉丁舞",
          "id":"402881ed649d628e01649d636ea7005c"
        },
        {
          "groupType":"avocation",
          "name":"少儿舞蹈",
          "id":"402881ed649d628e01649d636ea80067"
        },
        {
          "groupType":"avocation",
          "name":"广场舞",
          "id":"402881ed649d628e01649d636ea60055"
        },
        {
          "groupType":"avocation",
          "name":"摩登舞",
          "id":"402881ed649d628e01649d636ea7005d"
        },
        {
          "groupType":"avocation",
          "name":"健身舞",
          "id":"ff808081683f388401686177be49329c"
        },
        {
          "groupType":"avocation",
          "name":"舞蹈教学",
          "id":"ff80808167d9e1280167e45526397383"
        },
        {
          "groupType":"avocation",
          "name":"韩舞",
          "id":"ff80808167bec85c0167bee5673804a8"
        },
        {
          "groupType":"avocation",
          "name":"舞蹈学习",
          "id":"ff8080816821555e016827cff049029e"
        },
        {
          "groupType":"avocation",
          "name":"当代舞",
          "id":"402881ed649d628e01649d636ea7005e"
        },
        {
          "groupType":"avocation",
          "name":"尊巴",
          "id":"ff80808167d0594a0167d11b396d2cea"
        },
        {
          "groupType":"avocation",
          "name":"热门舞蹈",
          "id":"ff808081683f378701687690e06e66ac"
        },
        {
          "groupType":"avocation",
          "name":"原创编舞",
          "id":"ff80808167d9dd620167e457f899789a"
        },
        {
          "groupType":"avocation",
          "name":"钢管舞",
          "id":"402881ed649d628e01649d636ea70060"
        },
        {
          "groupType":"avocation",
          "name":"舞蹈表演",
          "id":"ff808081682b35530168326056c72e53"
        },
        {
          "groupType":"avocation",
          "name":"成人舞蹈",
          "id":"ff8080816960e987016962b2af0f5323"
        },
        {
          "groupType":"avocation",
          "name":"基本功",
          "id":"ff80808167effef30167f390c2bf6b63"
        },
        {
          "groupType":"avocation",
          "name":"交谊舞",
          "id":"402881ed649d628e01649d636ea70061"
        },
        {
          "groupType":"avocation",
          "name":"啦啦队舞",
          "id":"402881ed649d628e01649d636ea80064"
        },
        {
          "groupType":"avocation",
          "name":"流行舞",
          "id":"ff80808167d058740167d536d4653170"
        },
        {
          "groupType":"avocation",
          "name":"hiphop",
          "id":"ff80808167c027b90167c15425b95e52"
        },
        {
          "groupType":"avocation",
          "name":"踢踏舞",
          "id":"402881ed649d628e01649d636ea80063"
        },
        {
          "groupType":"avocation",
          "name":"中国风",
          "id":"ff80808167c026c90167c1fbde74258b"
        },
        {
          "groupType":"avocation",
          "name":"蒙古舞",
          "id":"ff80808167c026c90167c041fadb0751"
        },
        {
          "groupType":"avocation",
          "name":"舞蹈展演",
          "id":"ff80808167f9b7a60167ff35146b464d"
        },
        {
          "groupType":"avocation",
          "name":"儿童舞蹈",
          "id":"ff80808167c6b44f0167c9ec35630d8e"
        },
        {
          "groupType":"avocation",
          "name":"独舞",
          "id":"ff80808167d9e1280167d9f7b53003e7"
        },
        {
          "groupType":"avocation",
          "name":"群舞",
          "id":"ff80808167c026c90167c06ba8e914b1"
        },
        {
          "groupType":"avocation",
          "name":"音乐",
          "id":"ff808081683f3fa60168404729f62295"
        },
        {
          "groupType":"avocation",
          "name":"kpop",
          "id":"ff80808168a378820168a4797e0c2dbc"
        },
        {
          "groupType":"avocation",
          "name":"减肥",
          "id":"ff8080816913923c01691a8535d27dcf"
        },
        {
          "groupType":"avocation",
          "name":"塑形",
          "id":"ff808081682b3b6c0168322691b520e6"
        },
        {
          "groupType":"avocation",
          "name":"舞蹈赛事",
          "id":"ff80808175401165017545dfc83939a1"
        },
        {
          "groupType":"avocation",
          "name":"技术技巧",
          "id":"ff80808167effef30167f409012a022c"
        },
        {
          "groupType":"avocation",
          "name":"藏族舞",
          "id":"ff80808167d058740167d0f1026a22f6"
        },
        {
          "groupType":"avocation",
          "name":"印度舞",
          "id":"ff80808167d9dd830167e008f7d4673b"
        },
        {
          "groupType":"avocation",
          "name":"舞动中国梦",
          "id":"ff808081756d3db401756e0271925246"
        },
        {
          "groupType":"avocation",
          "name":"舞蹈艺考",
          "id":"ff80808167f9b1f60168124667dd182a"
        },
        {
          "groupType":"avocation",
          "name":"新疆舞",
          "id":"ff80808167c47d390167c56eee61696a"
        },
        {
          "groupType":"avocation",
          "name":"女团舞蹈",
          "id":"ff8080816b4b4bf7016b9dcb44805b8d"
        },
        {
          "groupType":"avocation",
          "name":"傣族舞",
          "id":"ff80808167cb37250167ce02a15c5f4c"
        },
        {
          "groupType":"avocation",
          "name":"舞蹈视频",
          "id":"ff8080816ad9c6e9016ae3692f984dd7"
        },
        {
          "groupType":"avocation",
          "name":"手势舞",
          "id":"ff80808168a376ba0168a73724526261"
        },
        {
          "groupType":"avocation",
          "name":"教学",
          "id":"ff808081682b399d016831a3f6d106dc"
        },
        {
          "groupType":"avocation",
          "name":"民间舞",
          "id":"ff80808167d9e1280167dbd1e94f6149"
        },
        {
          "groupType":"avocation",
          "name":"简单舞蹈",
          "id":"ff80808167c6d7c00167c6f32df20f0a"
        },
        {
          "groupType":"avocation",
          "name":"体育舞蹈",
          "id":"ff808081688495700168927b2efe4fc1"
        },
        {
          "groupType":"avocation",
          "name":"编舞",
          "id":"ff80808167e546cf0167eac433f273c4"
        },
        {
          "groupType":"avocation",
          "name":"国标舞",
          "id":"ff80808167cb37250167ceb6049b77ee"
        },
        {
          "groupType":"avocation",
          "name":"幼儿舞蹈",
          "id":"ff80808167c47c220167c5745f426bdc"
        },
        {
          "groupType":"avocation",
          "name":"中国古典舞",
          "id":"ff80808169d7f8ae0169d89e04724233"
        },
        {
          "groupType":"avocation",
          "name":"舞蹈比赛",
          "id":"ff80808167e53df20167e853b3c963b5"
        },
        {
          "groupType":"avocation",
          "name":"宝莱坞",
          "id":"ff80808168a94a970168d106032437cc"
        },
        {
          "groupType":"avocation",
          "name":"原创",
          "id":"ff80808169e335260169edf24e61173b"
        },
        {
          "groupType":"avocation",
          "name":"年会舞蹈",
          "id":"ff80808167e543490167e8c80ac17f74"
        }
      ],
      userHobby:["独舞","古典舞","爵士舞",] 
    }
    
  }),

	actions: {
    // 退出登录
    reset () {
      // 删除local中保存的token
      removeToken()
      // 提交重置用户信息的mutation
      this.token = ''
      this.userinfo.name = ''
      this.userinfo.avatar = ''
    },
	},
});
